﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ProjScan.RecordManager.AssetData;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.RecordManager
{
	// Token: 0x0200027F RID: 639
	internal class ModelRecordManager : RecordManagerBase<ModelAssetData>
	{
		// Token: 0x060010EC RID: 4332 RVA: 0x0004ED68 File Offset: 0x0004CF68
		public override void PrepareAssets()
		{
			this.datas = new List<ModelAssetData>();
			string[] array = new string[]
			{
				"fbx",
				"asset",
				"obj",
				"mesh"
			};
			int num = AssetPathManager.Instance.artPathList.Length;
			for (int i = 0; i < num; i++)
			{
				string text = AssetPathManager.Instance.artPathList[i];
				string text2 = Path.GetExtension(text).ToLower().Replace(".", "");
				bool flag = Enumerable.Contains<string>(array, text2);
				if (flag)
				{
					this.ActiveAllRecord();
					bool flag2 = this.EnableRule(text);
					if (flag2)
					{
						ModelImporter modelImporter = AssetImporter.GetAtPath(text) as ModelImporter;
						bool flag3 = modelImporter != null;
						if (flag3)
						{
							GameObject gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(text);
							bool flag4 = gameObject != null;
							if (flag4)
							{
								int id = AssetPathManager.Instance.GetID(Path.GetDirectoryName(text));
								string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
								ModelAssetData modelAssetData = new ModelAssetData(id, text, fileNameWithoutExtension, gameObject, modelImporter);
								modelAssetData.id = this.datas.Count;
								this.CheckAssets(modelAssetData);
								modelAssetData.Reset();
								this.datas.Add(modelAssetData);
								bool flag5 = this.datas.Count % 100 == 0;
								if (flag5)
								{
									ToolsHelper.GC();
								}
							}
						}
					}
				}
			}
		}

		// Token: 0x1700037D RID: 893
		// (get) Token: 0x060010ED RID: 4333 RVA: 0x0004EED8 File Offset: 0x0004D0D8
		public override string TableTag
		{
			get
			{
				return "model";
			}
		}
	}
}
